package chapter3;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author ycj
 * @version 1.0
 * @description: TODO
 * @date 2022/5/17
 */

//CAS
public class Source3_18 {
    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(888);
        System.out.println(atomicInteger.compareAndSet(888,666)+"\t"+atomicInteger.get());
        System.out.println(atomicInteger.compareAndSet(888,666)+"\t"+atomicInteger.get());
//        true	666
//        false	666

    }
}